package com.dyw.spzx.manager.service.lmpl;

import com.dyw.spzx.manager.mapper.ProductSpecMapper;
import com.dyw.spzx.manager.service.ProductSpecService;
import com.dyw.spzx.model.entity.product.ProductSpec;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductSpecServiceImpl implements ProductSpecService {
    @Autowired
    private ProductSpecMapper productSpecMapper;

    // 分页查询商品规格
    @Override
    public PageInfo<ProductSpec> findByPage(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<ProductSpec> specList = productSpecMapper.selectAllByPage();
        PageInfo<ProductSpec> specPageInfo = new PageInfo<>(specList);
        return specPageInfo;
    }

    // 添加商品规格
    @Override
    public void save(ProductSpec productSpec) {
        productSpecMapper.insertProductSpec(productSpec);
    }

    // 修改商品规格
    @Override
    public void updateSpec(ProductSpec productSpec) {
        productSpecMapper.updateSpec(productSpec);
    }

    // 删除商品规格
    @Override
    public void deleteSpec(Long id) {
        productSpecMapper.deleteSpec(id);
    }

    // 查询所有商品规格
    @Override
    public List<ProductSpec> findAll() {
        List<ProductSpec> productSpecList = productSpecMapper.selectAllProductSpec();
        return productSpecList;
    }


}
